|
ARD2
1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
|
00001 00017 #ifndef _SIU_H 00018 #define _SIU_H 00019 00020 /* 00021 ************************************************************** 00022 * Defines, Macros and Typedefs 00023 **************************************************************/ 00024 /*** Constant Macros ***/ 00026 #ifndef TRUE 00027 #define TRUE (1u) 00028 #endif 00029 #ifndef CLEAR 00030 #define CLEAR (0u) 00031 #endif 00032 #ifndef BIT_DEFINITION 00033 #define BIT_DEFINITION 00034 #define BIT0 (1u << 0u) 00035 #define BIT1 (1u << 1u) 00036 #define BIT2 (1u << 2u) 00037 #define BIT3 (1u << 3u) 00038 #define BIT4 (1u << 4u) 00039 #define BIT5 (1u << 5u) 00040 #define BIT6 (1u << 6u) 00041 #define BIT7 (1u << 7u) 00042 #define BIT8 (1u << 8u) 00043 #define BIT9 (1u << 9u) 00044 #define BIT10 (1u << 10) 00045 #define BIT11 (1u << 11) 00046 #define BIT12 (1u << 12) 00047 #define BIT13 (1u << 13) 00048 #define BIT14 (1u << 14) 00049 #define BIT15 (1u << 15) 00050 #define BIT16 (1u << 16) 00051 #define BIT17 (1u << 17) 00052 #define BIT18 (1u << 18) 00053 #define BIT19 (1u << 19) 00054 #define BIT20 (1u << 20) 00055 #define BIT21 (1u << 21) 00056 #define BIT22 (1u << 22) 00057 #define BIT23 (1u << 23) 00058 #define BIT24 (1u << 24) 00059 #define BIT25 (1u << 25) 00060 #define BIT26 (1u << 26) 00061 #define BIT27 (1u << 27) 00062 #define BIT28 (1u << 28) 00063 #define BIT29 (1u << 29) 00064 #define BIT30 (1u << 30) 00065 #define BIT31 (1u << 31) 00066 #endif 00067 00069 #define PIN_CONFIG_REGISTER_MAX (108u) 00070 #define N_PINS_PER_PORT (16u) 00071 #define N_INPUT_PADS (36u) 00072 00074 #define PIN_SAFE_MODE_EN (0x4000u) 00075 #define PIN_SAFE_MODE_DIS (0x0000u) 00076 #define PIN_ANALOG_EN (0x2000u) 00077 #define PIN_ANALOG_DIS (0x0000u) 00078 #define PIN_PAD_GPIO (0x0000u) 00079 #define PIN_PAD_ALT1 (0x0400u) 00080 #define PIN_PAD_ALT2 (0x0800u) 00081 #define PIN_PAD_ALT3 (0x0C00u) 00082 #define PIN_OUTPUT_BUF_EN (0x0200u) 00083 #define PIN_OUTPUT_BUF_DIS (0x0000u) 00084 #define PIN_INPUT_BUF_EN (0x0100u) 00085 #define PIN_INPUT_BUF_DIS (0x0000u) 00086 #define PIN_OPEN_DRAIN_OUT (0x0020u) 00087 #define PIN_PUSH_PULL_OUT (0x0000u) 00088 #define PIN_FAST_SLEW_RATE (0x0004u) 00089 #define PIN_SLOW_SLEW_RATE (0x0000u) 00090 #define PIN_WEAK_PULL_ASSERT (0x0002u) 00091 #define PIN_WEAK_PULL_NEGATE (0x0000u) 00092 #define PIN_WEAK_PULL_DIS (0x0001u) 00093 #define PIN_WEAK_PULL_EN (0x0000u) 00094 00095 /* Input Pad option */ 00096 #define PAD_SEL0 0u 00097 #define PAD_SEL1 1u 00098 #define PAD_SEL2 2u 00099 #define PAD_SEL3 3u 00100 #define PAD_SEL4 4u 00101 #define PAD_SEL5 5u 00102 #define PAD_SEL6 6u 00103 #define PAD_SEL7 7u 00104 #define PAD_SEL8 8u 00105 #define PAD_SEL9 9u 00106 #define PAD_SELA Au 00107 #define PAD_SELB Bu 00108 #define PAD_SELC Cu 00109 #define PAD_SELD Du 00110 #define PAD_SELE Eu 00111 #define PAD_SELF Fu 00112 00113 00114 /* Some predefines */ 00116 #define PIN_DISABLED (PIN_SAFE_MODE_DIS | PIN_ANALOG_DIS | \ 00117 PIN_PAD_GPIO | PIN_OUTPUT_BUF_DIS | \ 00118 PIN_INPUT_BUF_DIS | PIN_PUSH_PULL_OUT | \ 00119 PIN_SLOW_SLEW_RATE | PIN_WEAK_PULL_NEGATE | \ 00120 PIN_WEAK_PULL_EN) 00121 00122 #define PIN_ANALOG_CONFIG (PIN_SAFE_MODE_DIS | PIN_ANALOG_EN | \ 00123 PIN_PAD_GPIO | PIN_OUTPUT_BUF_DIS | \ 00124 PIN_INPUT_BUF_DIS | PIN_PUSH_PULL_OUT | \ 00125 PIN_SLOW_SLEW_RATE | PIN_WEAK_PULL_ASSERT | \ 00126 PIN_WEAK_PULL_DIS) 00127 #define PIN_PROGRAM (PIN_INPUT_BUF_EN | PIN_WEAK_PULL_ASSERT) 00128 00129 #define PIN_GPO_DEFAULT_CONFIG (PIN_SAFE_MODE_DIS | PIN_ANALOG_DIS | \ 00130 PIN_PAD_GPIO | PIN_OUTPUT_BUF_EN | \ 00131 PIN_INPUT_BUF_DIS | PIN_PUSH_PULL_OUT | \ 00132 PIN_SLOW_SLEW_RATE | PIN_WEAK_PULL_ASSERT | \ 00133 PIN_WEAK_PULL_DIS) 00134 #define PIN_MISO_CONFIG (PIN_SAFE_MODE_DIS | PIN_ANALOG_DIS | \ 00135 PIN_PAD_GPIO | PIN_OUTPUT_BUF_EN | \ 00136 PIN_INPUT_BUF_EN | PIN_OPEN_DRAIN_OUT | \ 00137 PIN_FAST_SLEW_RATE | PIN_WEAK_PULL_NEGATE | \ 00138 PIN_WEAK_PULL_DIS) 00139 00140 #define PIN_GPI_DEFAULT_CONFIG (PIN_SAFE_MODE_DIS | PIN_ANALOG_DIS | \ 00141 PIN_PAD_GPIO | PIN_OUTPUT_BUF_DIS | \ 00142 PIN_INPUT_BUF_EN | PIN_PUSH_PULL_OUT | \ 00143 PIN_SLOW_SLEW_RATE | PIN_WEAK_PULL_ASSERT | \ 00144 PIN_WEAK_PULL_DIS) 00145 00146 #define PIN_GPIO_DEFAULT_CONFIG (PIN_SAFE_MODE_DIS | PIN_ANALOG_DIS | \ 00147 PIN_PAD_GPIO | PIN_OUTPUT_BUF_EN | \ 00148 PIN_INPUT_BUF_EN | PIN_PUSH_PULL_OUT | \ 00149 PIN_SLOW_SLEW_RATE | PIN_WEAK_PULL_ASSERT | \ 00150 PIN_WEAK_PULL_DIS) 00151 00152 #define PIN_ALT1_CONFIG (PIN_SAFE_MODE_DIS | PIN_ANALOG_DIS | \ 00153 PIN_PAD_ALT1 | PIN_OUTPUT_BUF_DIS | \ 00154 PIN_INPUT_BUF_DIS | PIN_PUSH_PULL_OUT | \ 00155 PIN_SLOW_SLEW_RATE | PIN_WEAK_PULL_NEGATE | \ 00156 PIN_WEAK_PULL_EN) 00157 00158 #define PIN_ALT2_CONFIG (PIN_SAFE_MODE_DIS | PIN_ANALOG_DIS | \ 00159 PIN_PAD_ALT2 | PIN_OUTPUT_BUF_DIS | \ 00160 PIN_INPUT_BUF_DIS | PIN_PUSH_PULL_OUT | \ 00161 PIN_SLOW_SLEW_RATE | PIN_WEAK_PULL_NEGATE | \ 00162 PIN_WEAK_PULL_EN) 00163 00164 #define PIN_ALT3_CONFIG (PIN_SAFE_MODE_DIS | PIN_ANALOG_DIS | \ 00165 PIN_PAD_ALT3 | PIN_OUTPUT_BUF_DIS | \ 00166 PIN_INPUT_BUF_DIS | PIN_PUSH_PULL_OUT | \ 00167 PIN_SLOW_SLEW_RATE | PIN_WEAK_PULL_NEGATE | \ 00168 PIN_WEAK_PULL_EN) 00169 00170 #define PAD_DOES_NOT_EXIST ((uint8_t)0x20u) 00171 #define SIU_INVALID_PIN_CONFIGURATION ((uint8_t)0x80u) 00172 00173 /*** Function Macros ***/ 00174 00175 /*** Enums ***/ 00177 enum PAD_INPUT_CHANNELS 00178 { 00179 PAD_EXT_IN = 0, PAD_DSPI2_SCK, PAD_DSPI2_SIN, PAD_DSPI2_CS0, PAD_DSPI3_SCK, 00180 PAD_DSPI3_SIN, PAD_DSPI3_CS0, PAD_ETIMER0_ETC4, PAD_ETIMER0_ETC5, 00181 PAD_ETIMER1_ETC0, PAD_ETIMER1_ETC1, PAD_ETIMER1_ETC2, PAD_ETIMER1_ETC3, 00182 PAD_ETIMER1_ETC4, PAD_ETIMER1_ETC5, PAD_PWM0_EXT_SYNC, PAD_PWM0_FAULT0, 00183 PAD_PWM0_FAULT1, PAD_PWM0_FAULT2, PAD_PWM0_FAULT3, PAD_PWM0_PWMA0, 00184 PAD_PWM0_PWMA1, PAD_PWM0_PWMA2, PAD_PWM0_PWMA3, PAD_PWM0_PWMB0, 00185 PAD_PWM0_PWMB1, PAD_PWM0_PWMB2, PAD_PWM0_PWMB3, PAD_PWM_PWMX1, 00186 PAD_PWM_PWMX2, PAD_PWM_PWMX3, PAD_LIN0_RXD, PAD_LIN1_RXD 00187 }; 00188 /*** TypeDefs ***/ 00189 typedef union 00190 { 00191 struct 00192 { 00193 vuint8_t Reserved: 1u; 00194 vuint8_t RisingEdgeEn: 1u; 00195 vuint8_t FallingEdgeEn: 1u; 00196 vuint8_t GlitchFiltEn: 1u; 00197 vuint8_t IRQEn: 1u; 00198 }P; 00199 vuint8_t A; 00200 } IRQConfig_t; 00201 /* 00202 ************************************************************** 00203 * Declarations 00204 **************************************************************/ 00205 /*** Extern ***/ 00206 00207 /*** Globals ***/ 00208 00209 /*** Static Globals ***/ 00210 00211 /* 00212 ************************************************************** 00213 * Function Prototypes 00214 **************************************************************/ 00215 /* 00216 ****************************************************************************** 00217 * 00218 * Function: vfnConfigDefaultPinBehavior() 00219 * 00220 */ 00231 void vfnConfigDefaultPinBehavior(const uint16_t* pu16Config, \ 00232 uint8_t u8Offset, uint8_t u8ConfigSize); 00233 /* 00234 ****************************************************************************** 00235 * 00236 * Function: vfnToggleOutputPin() 00237 * 00238 */ 00251 void vfnToggleOutputPin(const uint8_t u8Port, const uint8_t u8Pin, \ 00252 const uint8_t u8Level); 00253 /* 00254 ****************************************************************************** 00255 * 00256 * Function: u8fnReadPin() 00257 * 00258 */ 00271 uint8_t u8fnReadPin(const uint8_t u8Port, const uint8_t u8Pin); 00272 /* 00273 ****************************************************************************** 00274 * 00275 * Function: u8fnReturnPinIndex() 00276 * 00277 */ 00287 uint8_t u8fnReturnPinIndex(const uint8_t u8Port, const uint8_t u8Pin); 00288 /* 00289 ****************************************************************************** 00290 * 00291 * Function: u8fnRouteInputPad() 00292 * 00293 */ 00303 uint8_t u8fnRouteInputPad(const uint8_t u8Module, const uint8_t u8PinIndex); 00304 /* 00305 ****************************************************************************** 00306 * 00307 * Function: u8fnIRQConfig() 00308 * 00309 */ 00319 uint8_t u8fnIRQConfig(uint8_t u8Channel, IRQConfig_t tConfig); 00320 /* 00321 ****************************************************************************** 00322 * 00323 * Function: vfnIRQClearIsrFlag() 00324 * 00325 */ 00332 void vfnIRQClearIsrFlag(uint8_t u8Channel); 00333 00334 #endif /* _FILENAME_H */